import { requestDetailInfo } from "@/api"
const state={
    detailInfo:{}
}
const mutations ={
    SET_DETAILINFO_STATE(state,value){
        state.detailInfo = value
    }
}
const actions={
    async getdetailInfo({commit},skuId){
        const result  = await requestDetailInfo(skuId)
        commit("SET_DETAILINFO_STATE",result)
    }
}
const getters ={
    categoryView(state){
                //因为请求是异步的 所有初始的时候可以设置一个空对象或者数组 以免报错
        return state.detailInfo.categoryView || {}
    },
    spuSaleAttrList(state){
        return state.detailInfo.spuSaleAttrList || []
    },
    skuInfo(state){
        return state.detailInfo.skuInfo || {}
    }
}
export default {
    namespaced:true,
    state,
    mutations,
    getters,
    actions
}